<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
	<div class="container-div">
		<!-- <div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="dept-form">
					<div class="select-list">
						<ul>
							<li>
								部门名称：<input type="text" name="deptName"/>
							</li>
							<li>
								部门状态：<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
                
            <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
		        <a class="btn btn-success" onclick="$.operate.add(100)" shiro:hasPermission="system:dept:add">
                    <i class="fa fa-plus"></i> 新增
                </a>
                <a class="btn btn-primary" onclick="$.operate.editTree()" shiro:hasPermission="system:dept:edit">
		            <i class="fa fa-edit"></i> 修改
		        </a>
                <a class="btn btn-info" id="expandAllBtn">
                    <i class="fa fa-exchange"></i> 展开/折叠
                </a>
	        </div>
       		 <div class="col-sm-12 select-table table-striped">
	            <table id="bootstrap-table" data-mobile-responsive="true"></table>
	        </div>
	    </div> -->
	    <div class="row">
			<div class="col-sm-12 search-collapse">
				<!--<form id="integralMenu-form">
					<div class="select-list">
						<ul>
							<li>
								类别名称：<input type="text" name="typeName"/>
							</li>

							<li>
							类别状态：<select name="status" th:with="type=${@dict.getType('integralMenu_type_disable')}" class="form-control m-b-none">
							<option value="">所有</option>
							<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>-->
			</div>
			<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add(id=1)" shiro:hasPermission="integral:integralMenu:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<!--<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="integral:integralMenu:edit">
		            <i class="fa fa-edit"></i> 修改
		        </a>-->
		        <a class="btn btn-info" id="expandAllBtn">
                    <i class="fa fa-exchange"></i> 展开/折叠
                </a>
				<!--<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="integral:integralMenu:remove">
					<i class="fa fa-remove"></i> 删除
				</a>-->
			</div>

			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
	<div th:include="include :: footer"></div>
	<script th:src="@{/ajax/libs/select/select2.js}"></script>
	<script th:inline="javascript">
		var addFlag = [[${@permission.hasPermi('integral:integralMenu:add')}]];
		var editFlag = [[${@permission.hasPermi('integral:integralMenu:edit')}]];
		var removeFlag = [[${@permission.hasPermi('integral:integralMenu:remove')}]];
		var datas = [[${@dict.getType('sys_normal_disable')}]];
		var prefix = ctx + "integral/integralMenu"

		$(function() {
		    var options = {
		        code: "id",
		        parentCode: "pId",
		        uniqueId: "id",
		        url: prefix + "/treeData",
		        createUrl: prefix + "/add/{id}",
		        updateUrl: prefix + "/edit/{id}",
		        removeUrl: prefix + "/remove/{id}",
		        modalName: "积分菜单管理",
                expandAll: false,
                expandFirst: true,
		        columns: [{
                    field: 'selectItem', 
                    radio: true
				},
				{
		            field: 'name',
		            title: '类别名称	',
		            align: "left",
		            width: '204px'
		        },
		        {
		        	field: 'status',
		        	title: '使用状态',
		        	formatter: function (value) {
						switch (value) {
							case 0: return '<span class="badge badge-info">使用中</span>';
							case 1: return '<span class="badge badge-danger">已禁用</span>';
                        }
                    }
		        },
				{
					field : 'typeId',
					title : '积分类型',
					formatter: function (value) {
						switch (value) {
							case 1: return '品德A分';
							case 2: return '业绩B分';
							case 3: return '行为C分';
						}
					}
				},
		        {
		            field: 'createTime',
		            title: '创建时间',
		            align: "left"
		        },
				{
					field: 'updateTime',
					title: '更改时间',
					align: 'left'
				},
		        {
		            title: '操作',
		            align: 'left',
		            width: '240px',
		            formatter: function(value, row, index) {
	                    var actions = [];
	                    if (row.pId > 1) {
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit">编辑</i></a> ');
                            // actions.push('<a class="btn btn-warning btn-xs ' +  + '" href="#" onclick="$.operate.editApproval(\'' + row.id + '\')"><i class="fa fa-edit">审批设置</i></a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id +'\')"><i class="fa fa-key"></i>删除</a> ');
			            }
	                    return actions.join('');
		            }
		        }]
		    };
		    $.treeTable.init(options);
		});
		
		// function remove(id) {
		// 	$.modal.confirm("确定删除该条" + $.table._option.modalName + "信息吗？", function() {
		// 		$.ajax({
		// 			type : 'post',
		// 			url: prefix + "/remove/" + id,
		// 			success : function(result) {
		// 				if (result.code == web_status.SUCCESS) {
		//                 	$.modal.msgSuccess(result.msg);
		//                 	$.treeTable.refresh();
		//                 } else {
		//                 	$.modal.msgError(result.msg);
		//                 }
		// 			}
		// 		});
		// 	});
		// }
	</script>
</body>
</html>